package com.portal.innovation.sysController;


import com.portal.innovation.utils.PageUtils;
import com.portal.innovation.common.R;
import com.portal.innovation.pojo.TeacherInfo;
import com.portal.innovation.service.TeacherInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;

/**
 * 文件上传控制器
 */
@RestController
@RequestMapping("/teacher")
public class TeacherInfoController {


    @Autowired
    private TeacherInfoService teacherInfoService;

    @PostMapping("list")
    public R save(@RequestBody HashMap params) {
        PageUtils page = teacherInfoService.queryPage(params);
        return R.ok().put("page", page);
    }

    @PostMapping("save")
    public R save(@RequestBody TeacherInfo teacherInfo) {
        teacherInfoService.save(teacherInfo);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R save(@RequestBody Integer[] ids) {
        teacherInfoService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

    @PostMapping("update")
    public R update(@RequestBody TeacherInfo teacherInfo) {
        teacherInfoService.updateById(teacherInfo);
        return R.ok();
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        TeacherInfo teacherInfo = teacherInfoService.getById(id);
        return R.ok().put("teacherInfo", teacherInfo);
    }

}
